package net.huashitong.synthetical.TaskJob.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.synthetical.TaskJob.Entity.TaskSituation;
import net.huashitong.synthetical.TaskJob.filter.TaskSituationFilter;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 落实情况
 */
@Repository
public class TaskSituationDao extends StringDao<TaskSituation> {


    /**
     * 获取落实情况
     * @param taskId
     * @return
     */
    public List<TaskSituation> getTaskId(String taskId){
        GenericQuery query = createQuery("obj");
        if (taskId!=null&&!"".equals(taskId)) {
            query.append("and taskId=:taskId").setParam("taskId", taskId);
        }
        return query.listResult();
    }
    /**
     * 查询落实情况列表主入口
     *
     * @param filter
     * @return
     */
    public List<TaskSituation> getTaskSituationList(TaskSituationFilter filter) {
        GenericQuery query = createQuery("obj");
        if (filter.getSysId() != null && "".equals(filter.getSysId())) {
            query.append("and sysId =:sysId").setParam("sysId", filter.getSysId());
        }
        if (filter.getDeptCode() != null && "".equals(filter.getDeptCode())) {
            query.append("and deptCode =:deptCode").setParam("deptCode", filter.getDeptCode());
        }
        if (filter.getDepart() != null && "".equals(filter.getDepart())) {
            query.append("and depart like:depart").setParam("depart", StringUtils.getLikewords(filter.getDepart()));
        }
        if (filter.getNowSituation() != null && "".equals(filter.getNowSituation())) {
            query.append("and nowSituation like:nowSituation").setParam("nowSituation", StringUtils.getLikewords(filter.getNowSituation()));
        }
        if (filter.getProblem()!=null&&"".equals(filter.getProblem())){
            query.append("and problem like:problem").setParam("problem",StringUtils.getLikewords(filter.getProblem()));
        }
        if(filter.getNextPlan()!=null&&"".equals(filter.getNextPlan())){
            query.append("and nextPlan like:nextPlan").setParam("nextPlan",StringUtils.getLikewords(filter.getNextPlan()));
        }
        return query.listResult(filter);
    }


}
